package com.example.demo.service.impl;

import com.example.demo.demos.web.User;

import java.util.ArrayList;
import java.util.List;

public class DemoTest {

    public static void main(String[] args) {
        List<User> userList = new ArrayList<>(6);
        userList.add(new User(1L, "Tom", 19));
        userList.add(new User(2L, "Giles", 25));
        userList.add(new User(3L, "Alex", null));
        userList.add(new User(4L, "Ryan", 21));
        userList.add(new User(5L, "DongGe", 19));
        userList.add(new User(6L, "RUI", 21));

        userList.forEach(user -> {
            String name = user.getName();
            Integer age = user.getAge();
            int futureAge = (age != null) ? age + 10 : 0; // 防止空指针
            System.out.println(name + " 10年后 " + futureAge + " 岁");
        });
    }

}
